package com.swordliu.facebook.controller;

import com.swordliu.facebook.controller.base.BaseController;
import com.swordliu.facebook.pojo.entity.User;
import com.swordliu.facebook.service.UserService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * UserController
 * Created by SwordLiu on 2017-07-20.
 */
@Controller
@RequestMapping("/user")
public class UserController extends BaseController {

    @Autowired
    private UserService userService;

    @RequiresRoles("sys")
    @RequestMapping("/users.do")
    public String users(Model model) throws Exception {
        List<User> users = userService.getUsers();
        model.addAttribute("users", users);
        return "page/sys/user";
    }

}
